package ray;

import java.awt.Color;
import java.awt.geom.Point2D;

import scene.IntersectionInfo;
import scene.Scene;
import util.Point3D;

public class CameraRay extends Ray {

	private Point2D pixel;
	
	public CameraRay(Point3D start, Point3D end, Point2D pixel) {
		super(start, end);
		
		this.pixel = pixel;
	}

	@Override
	public Color getColor() {
		Color color = null;
		IntersectionInfo intersect = Scene.getInstance().getClosestIntersection(this);
		if(intersect == null) {
			color = Scene.getInstance().getBackgroundColor();
		} else {
			color = intersect.getObject().getBaseColor();
		}
		return color;
	}
	
	public Point2D getCorrespondingPixel() {
		return pixel;
	}

}
